/*
 * sourceData.js
 *
 * Depends on functionGenerators and noiseGenerators.
 *
 * COS452
 * Alex Grant
 */
function sourceDataObject() { }
sourceDataObject.prototype = {
	"noiseGenerator" : noNoise,                       // randNoise or whiteNoise or perlinNoise1D or noNoise
	"functionGenerator" : sineGenerator,         // source data generator

	"value" : 0,
	"noise" : 0,
	
	//--------------------------------------------------------------------------------------------
	// public methods
        //--------------------------------------------------------------------------------------------
		
	/*
	 * setNoiseGenerator
         * Dynamically sets the noiseGenerator
         */
	"setNoiseGenerator" : function(noiseOption) {			
		switch (noiseOption) {
			case 0: 
				this.noiseGenerator = noNoise;
				break;				
			case 1:
				this.noiseGenerator = whiteNoise;
				break;
			case 2:
				this.noiseGenerator = perlinNoise1D;
				break;
			case 3:
				this.noiseGenerator = randNoise;
				break;
			case 4:
				this.noiseGenerator = pinkNoise;
				break;
			case 5:
				this.noiseGenerator = brownNoise;
				break;
			
		} // switch
	},

	/*
	 * setFunctionGenerator
         * Dynamically sets the functionGenerator
         */
	"setFunctionGenerator" : function(functionOption) {
		switch (functionOption) {
			case 0:
				this.functionGenerator = sineGenerator;
				break;
			case 1:
				this.functionGenerator = lsysGenerator;
				break;
			case 2:
				this.functionGenerator = maryHALLGenerator;
				break;
		} // switch
	},
		
	/*
	 * getSourceData
	 * Returns the next input value and value with noise applied
	 * Updates this objects value and noise properties
	 * Object returned has "value" and "noise" properties
	 */
	"getSourceData" : function() {
		this.value = this.functionGenerator.getValue();
		this.noise = this.value + this.noiseGenerator.getValue(this.value);
		//alert("hi");
		return { value : this.value, noise : this.noise };
	},
	
	"getValue" : function() {
		return this.value;
	},
	
	"peekNextValue" : function() {
		return this.functionGenerator.peekNext();
	},
	
	"getValueMin" : function() {
		return this.functionGenerator.getMin();
	},
	
	"getValueMax" : function() {
		return this.functionGenerator.getMax();
	},
	
	"getNoise" : function() {
		return this.noise;
	}
}